<template>
  <div class="score-rank">
    <h1>积分排名</h1>
    <div>
      <el-card
        class="score-card"
        body-style="display: flex; align-items: center; justify-content: space-between;"
        v-for="user in users"
      >
        <div class="name-and-avatar">
          <el-avatar class="avatar" :src="user.avatar"></el-avatar>
          <x-user-detail-link :user-id="user.id" :link-name="user.name" />
        </div>
        <el-tag type="success">{{ user.score }}</el-tag>
      </el-card>
    </div>
  </div>
</template>

<script setup>
import { scoreRank } from "../../api/userAPI";

const users = ref([]);
// TODO: 2023-2-6 增加 分页参数
scoreRank().then(({ data }) => {
  users.value = data.data;
});
</script>

<style scoped>
.score-rank {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.score-card {
  margin-top: 10px;
  width: 500px;
}
.name-and-avatar {
  display: flex;
  justify-content: center;
  align-items: center;
}
.avatar {
  margin-right: 10px;
}
</style>
